package cn.lyz.craft.service.service.impl;

import cn.lyz.craft.service.entity.Menu;
import cn.lyz.craft.service.repository.MenuRepository;
import cn.lyz.craft.service.service.MenuService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class MenuServiceImpl implements MenuService {

    private final MenuRepository menuRepository;

    @Override
    public List<Menu> findByParentIsNull() {
        return menuRepository.findByParentIsNull();
    }

    @Override
    public Menu save(Menu menu) {
        return menuRepository.save(menu);
    }

    @Override
    public List<Menu> findAll() {
        return menuRepository.findAll();
    }

    @Override
    public Menu findById(Long id) {
        return menuRepository.findById(id).orElse(null);
    }

    @Override
    public void deleteById(Long id) {
        menuRepository.deleteById(id);
    }
}